import json
from selenium import webdriver
import time

 
str=''
with open('mycookie.json','r',encoding='utf-8') as f:
    listCookies=json.loads(f.read())
cookie = [item["name"] + "=" + item["value"] for item in listCookies]
cookiestr = '; '.join(item for item in cookie)
print(listCookies)


driver = webdriver.Chrome()
driver.get('https://www.dianxiaomi.com/package/toAdd.htm')


for cookie in listCookies:
    if 'expiry' in cookie:
        del cookie['expiry']
    driver.add_cookie(cookie)

driver.get('https://www.dianxiaomi.com/package/toAdd.htm')

driver.find_element_by_class_name("btn-gray").click()

js = "document.getElementById(\"select_btn_1\").style.display='block';"
# 调用js脚本
driver.execute_script(js)
time.sleep(3)

driver.find_element_by_xpath("/html/body/div[18]/div[2]/div[2]/button[1]").click()

driver.find_element_by_id('select_btn_1').send_keys(r'/Users/liuyue/wodfan/work/mytornado/cccc.xlsx')

time.sleep(2)

driver.find_element_by_xpath("/html/body/div[21]/div[2]/div/div[3]/button[1]").click()


time.sleep(60)
driver.close()








# import requests
# url='https://www.dianxiaomi.com/order/index.htm'
# headers={
#     'cookie':cookiestr,
#     'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36'
# }
# html=requests.get(url=url,headers=headers)
# print(html.text)